<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{$Think.lang.banlist}</title>
    <link rel="stylesheet" href="__ADMIN__/vendor/layui/css/layui.css">
    <link rel="stylesheet" href="__ADMIN__/custom/css/style.css">
</head>
<body style="padding:10px 10px;">
<form action="" class="layui-form">
<table class="layui-table" lay-size="sm">
    <colgroup>
        <col width="80">
        <col>
        <col width="300">
        <col width="100">
        <col width="100">
        <col width="150">
    </colgroup>
    <thead>
    <tr>
        <th style="text-align: center;">ID</th>
        <th>{$Think.lang.pic}</th>
        <th>{$Think.lang.title}</th>
        <th>{$Think.lang.isshow}</th>
        <th>{$Think.lang.sort}</th>
        <th>{$Think.lang.caoz}</th>
    </tr>
    </thead>
    <tbody>
    {volist name="banner" id="vo"}
    <tr>
        <td style="text-align: center;">{$vo.id}</td>
        <td><img src="/{$vo.pic}" height="50" alt=""></td>
        <td>{$vo.title}</td>

        <td><input type="checkbox" name="isshow" lay-skin="switch" value="{$vo.id}" lay-filter="isshow" lay-text="显示|隐藏" {$vo.isshow?"checked":""}></td>
        <td><input type="text" name="sort" value="{$vo.sort}" required lay-verify="required" placeholder="请输入排序" autocomplete="off" class="layui-input sort" data="{$vo.id}"></td>
        <td>
            <a href="{:url('banner/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-warm layui-btn-mini">{$Think.lang.edit}</a>
            <a href="{:url('banner/delete',array('id'=>$vo['id']))}" class="layui-btn layui-btn-danger layui-btn-mini del">{$Think.lang.del}</a></td>
    </tr>
    {/volist}
    </tbody>
</table>
</form>
<script src="__ADMIN__/vendor/js/jquery.js"></script>
<script src="__ADMIN__/vendor/layui/layui.js"></script>
<script src="__ADMIN__/custom/js/admin.js"></script>
<script>
    layui.use(['layer','form'], function(){
        var layer = layui.layer;
        var form  = layui.form;
        $('.del').on('click',function () {
            var url=$(this).attr('href');
            layer.confirm('确定要删除该轮播图吗?', {icon: 3, title:'温馨提示'}, function(index){
                //do something
                location.href=url;
                layer.close(index);
            });
            return false;
        });
        //显示与隐藏
        form.on('switch(isshow)', function(data){
            var value;
            value=data.elem.checked?1:0;
            $.post("{:url('admin/banner/setajax')}",{
                act:'show',
                'v':value,
                'id':data.value,
            },function(res){
                if(res.code==1){
                        layer.msg("操作成功",{time:1000,icon:1},function () {
                            location.reload();
                        })
                    }
            })
            
        });
        //排序
        $('.sort').change(function () {
            var id=$(this).attr('data');
            var value=$(this).val();
            $.post("{:url('admin/banner/setajax')}",{
                act:'sort',
                'v':value,
                'id':id,
            },function(res){
                if(res.code==1){
                        layer.msg("排序成功",{time:1000,icon:1},function () {
                            location.reload();
                        })
                    }
            })
        })
    });
    $(function(){
        $(window.parent.document).find('#righttitle').text($('title').text());
   });
</script>
</body>
</html>